[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Partition a list or array based on a predicate. After partitioning, all items for which
the predicate returned true precede all items for which the predicate returned false.
Namespace: Wintellect.PowerCollections
Assembly:
PowerCollections (in PowerCollections.dll)
Syntax
C# |
---|
public static int Partition<T>( IList<T> list, Predicate<T> predicate ) |
Visual Basic (Declaration) |
---|
Public Shared Function Partition(Of T) ( _ list As IList(Of T), _ predicate As Predicate(Of T) _ ) As Integer |
Visual C++ |
---|
public: generic<typename T> static int Partition ( IList<T>^ list, Predicate<T>^ predicate ) |
Parameters
- list
- IList<(Of <T>)>
The list or array to partition.
- predicate
- Predicate<(Of <T>)>
A delegate that defines the partitioning condition.
Return Value
The index of the first item in the second half of the partition; i.e., the first item for which predicate returned false. If the predicate was true for all items in the list, list.Count is returned.Type Parameters
- T
Remarks
Although arrays cast to IList<T> are normally read-only, this method
will work correctly and modify an array passed as list.
See Also
Algorithms Class
Wintellect.PowerCollections Namespace